#pragma once

#include <Windows.h>
#include <sal.h>

HRESULT WINAPI TraceW(_In_z_ const WCHAR* strFile, _In_ const WCHAR *strFunc, _In_ DWORD dwLine, _In_ HRESULT hr, _In_opt_ const WCHAR* strMsg, _In_ bool bSaveLog);


#if defined(DEBUG) | defined(_DEBUG)
#ifndef HR
#define HR(x)												\
	{															\
		HRESULT hr = (x);										\
		if(FAILED(hr))											\
		{														\
			TraceW(__FILEW__, __FUNCTIONW__, (DWORD)__LINE__, hr, L#x, false);\
		}														\
	}
#endif

#ifndef TRACE
#define TRACE(hr, str) \
		TraceW(__FILEW__, __FUNCTIONW__, (DWORD)__LINE__, (hr), (str), false);
#endif // !TRACE

#else
#ifndef HR
#define HR(x) (x)
#define TRACE(hr, str) \
		TraceW(__FILEW__, __FUNCTIONW__, (DWORD)__LINE__, (hr), (str), true);
#endif 
#endif
